package com.itfreer.gis.map.style;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itfreer.form.api.BaseRestService;
import com.itfreer.form.api.BaseService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.itfreer.gis.map.style.entity.MapStyleDirectoryEntity;
import com.itfreer.utils.ResponseEntity;

/**
 * 定义我的样式目录Rest服务接口
 */
@RestController
@RequestMapping("/gismapstyledirectory")
@Api("我的样式目录")
public class RestMapStyleDirectoryService extends BaseRestService<MapStyleDirectoryEntity> {

	@Autowired(required = false)
	private MapStyleDirectoryService service;

	@Reference(lazy = true, check = false)
	private MapStyleDirectoryService dubboService;

	@Override
	protected BaseService<MapStyleDirectoryEntity> getService() {
		return getServiceEx();
	}

	protected MapStyleDirectoryService getServiceEx() {
		if (service == null) {
            return dubboService;
        } else {
            return service;
        }
	}

	/**
	 * 获取推荐方案
	 */
	@ApiOperation(value = "获取推荐方案")
	@PostMapping(value = "recommend", produces = "application/json")
	private ResponseEntity<List<StyleInfo>> recommend() {
		return new ResponseEntity<List<StyleInfo>>(getServiceEx().recommend());
	}
}
